package cn.edu.tfswufe.pojo;

import java.util.ArrayList;
import java.util.List;

public class User {
    private String readerID; // 读者编号（主键）
    private String name;     // 姓名
    private String gender;   // 性别
    private int age;         // 年龄
    private String phone;    // 联系电话
    private String email;    // 电子邮箱
    private List<String> borrowedBooks; // 已借图书列表
    private int borrowLimit; // 借书额度



    public User(String readerID, String name, String gender, int age, String phone, String email, int borrowLimit) {
        this.readerID = readerID;
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.phone = phone;
        this.email = email;
        this.borrowedBooks = new ArrayList<>();
        this.borrowLimit = borrowLimit;
    }

    public String getReaderID() {
        return readerID;
    }

    public void setReaderID(String readerID) {
        this.readerID = readerID;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public List<String> getBorrowedBooks() {
        return borrowedBooks;
    }

    public void setBorrowedBooks(List<String> borrowedBooks) {
        this.borrowedBooks = borrowedBooks;
    }

    public int getBorrowLimit() {
        return borrowLimit;
    }

    public void setBorrowLimit(int borrowLimit) {
        this.borrowLimit = borrowLimit;
    }
    // 可选：添加一本已借书籍
    public boolean addBorrowedBook(String bookId) {
        if (borrowedBooks.size() < borrowLimit) {
            borrowedBooks.add(bookId);
            return true;
        }
        return false;
    }

    // 可选：移除一本已借书籍
    public boolean removeBorrowedBook(String bookId) {
        return borrowedBooks.remove(bookId);
    }
}
